package com.wpp.dubbo.filter;

import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.rpc.*;
import org.springframework.util.StopWatch;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;

/**
 * @Classname TPMonitorFilter
 * @Description
 * @Date 2021/1/20 20:50
 * @Created by wpp25
 */
@Activate(group = {CommonConstants.CONSUMER, CommonConstants.PROVIDER})
public class ConsumeTimeFilter implements Filter {



    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        StopWatch stopWatch = new StopWatch();
        try {
            stopWatch.start();
            return invoker.invoke(invocation);
        } finally {
            stopWatch.stop();
            System.out.println("invoker time:" +stopWatch.getTotalTimeMillis());
        }
    }


}
